﻿Imports System.Windows.Forms

Public Class CaptchaDialog
    Private Sub CaptchaDialog_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ''TODO: ADD AUDIO PLAYBACK OF CAPTCHA
        If My.Settings.sinetCountry = "ca" Then
            CaptchaBox.Width = 184
            CaptchaBox.Height = 65
            CaptchaBox.Location = New Point(7, 5)
            TextBoxCaptchaCode.MaxLength = 6
        ElseIf My.Settings.sinetCountry = "us" Then
            CaptchaBox.Location = New Point(35, 18)
            CaptchaBox.Width = 131
            CaptchaBox.Height = 39
            TextBoxCaptchaCode.MaxLength = 4
        End If
        TextBoxCaptchaCode.Text = Nothing
        TextBoxCaptchaCode.Focus()
        Me.AcceptButton = ButtonVerify
        Me.CancelTheButton = CancelTheButton
    End Sub

    Private Sub TextBoxCaptchaCode_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBoxCaptchaCode.TextChanged
        If (My.Settings.sinetCountry = "us" And TextBoxCaptchaCode.TextLength = 4) Or (My.Settings.sinetCountry = "ca" And TextBoxCaptchaCode.TextLength = 6) Then
            TextBoxCaptchaCode.BackColor = Color.GreenYellow
            ButtonVerify.Enabled = True
        Else
            TextBoxCaptchaCode.BackColor = Color.Red
            ButtonVerify.Enabled = False
        End If
    End Sub

    Private Sub CancelButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub ButtonVerify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonVerify.Click
        Main.captchaCode = TextBoxCaptchaCode.Text
        Me.DialogResult = Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub
End Class
